package com.ocom.payhandle.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ocom.common.entity.payconfig.EntityXfDeviceMealConfig;
import com.ocom.common.enums.DataSourceEnum;
import com.ocom.mysql.aspect.DataSourceAspect;
import com.ocom.payhandle.dao.IDaoXfDeviceMealConfig;
import com.ocom.payhandle.service.XfDeviceMealConfigServcie;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class XfDeviceMealConfigServcieImpl extends ServiceImpl<IDaoXfDeviceMealConfig, EntityXfDeviceMealConfig> implements XfDeviceMealConfigServcie {

    @DataSourceAspect(type = DataSourceEnum.PART_DB,companyId = "companyId")
    @Override
    public List<EntityXfDeviceMealConfig> selectVoucher(Long companyId, String machNo) {
        QueryWrapper<EntityXfDeviceMealConfig> query = Wrappers.query();
        query.eq("com_id",companyId);
        query.eq("device_no",machNo);
        return this.list(query);
    }

    @DataSourceAspect(type = DataSourceEnum.PART_DB,companyId = "companyId")
    @Override
    public List<EntityXfDeviceMealConfig> selectMealNo(Long companyId, Integer consType, String machNo) {
        QueryWrapper<EntityXfDeviceMealConfig> query = Wrappers.query();
        query.eq("com_id",companyId);
        query.eq("device_no",machNo);
        query.eq("cons_type",consType);
        return this.list(query);
    }
}
